namespace IrisGenerator.Common.DatabaseModel {
    using DAL = IrisGenerator.Common.DatabaseModel.DataAccess;
    using IrisGenerator.Common.Tools;
    
    public partial class RequestType {
        
        private System.Nullable<System.Guid> _reqTypId;
        
        private string _reqTypCode;
        
        private string _reqTypDescription;
        
        private RequestCollection _requestCollection;
        
        public virtual System.Nullable<System.Guid> ReqTypId {
            get {
                return _reqTypId;
            }
            set {
                _reqTypId = value;
            }
        }
        
        public virtual string ReqTypCode {
            get {
                return _reqTypCode;
            }
            set {
                _reqTypCode = value;
            }
        }
        
        public virtual string ReqTypDescription {
            get {
                return _reqTypDescription;
            }
            set {
                _reqTypDescription = value;
            }
        }
        
        public virtual RequestCollection RequestCollection {
            get {
                if ((this._requestCollection == null)) {
                    _requestCollection = IrisGenerator.Common.DatabaseModel.Request.Select_REQUEST_By_REQ_TYP_ID(this.ReqTypId);
                }
                return this._requestCollection;
            }
        }
        
        private void Clean() {
            this.ReqTypId = null;
            this.ReqTypCode = string.Empty;
            this.ReqTypDescription = string.Empty;
            this._requestCollection = null;
        }
        
        private void Fill(System.Data.DataRow dr) {
            this.Clean();
            if ((dr["REQ_TYP_ID"] != System.DBNull.Value)) {
                this.ReqTypId = ((System.Nullable<System.Guid>)(dr["REQ_TYP_ID"]));
            }
            if ((dr["REQ_TYP_CODE"] != System.DBNull.Value)) {
                this.ReqTypCode = ((string)(dr["REQ_TYP_CODE"]));
            }
            if ((dr["REQ_TYP_DESCRIPTION"] != System.DBNull.Value)) {
                this.ReqTypDescription = ((string)(dr["REQ_TYP_DESCRIPTION"]));
            }
        }
        
        public static RequestTypeCollection GetAll() {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                System.Data.DataSet ds = dbo.REQUEST_TYPE_Select_All();
                RequestTypeCollection collection = new RequestTypeCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        RequestType obj = new RequestType();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static RequestType Load(System.Nullable<System.Guid> REQ_TYP_ID) {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                System.Data.DataSet ds = dbo.REQUEST_TYPE_Select_One(REQ_TYP_ID);
                RequestType obj = null;
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        obj = new RequestType();
                        obj.Fill(ds.Tables[0].Rows[0]);
                    }
                }
                return obj;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Load() {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                System.Data.DataSet ds = dbo.REQUEST_TYPE_Select_One(this.ReqTypId);
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        this.Fill(ds.Tables[0].Rows[0]);
                    }
                }
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Insert() {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                dbo.REQUEST_TYPE_Insert(this.ReqTypCode, this.ReqTypDescription);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Delete() {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                dbo.REQUEST_TYPE_Delete(this.ReqTypId);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Update() {
            DAL.RequestType dbo = null;
            try {
                dbo = new DAL.RequestType();
                dbo.REQUEST_TYPE_Update(this.ReqTypId, this.ReqTypCode, this.ReqTypDescription);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
    }
}
